//
//  LYCommentModel.m
//  LYLiveApp
//
//  Created by QD on 16/8/29.
//  Copyright © 2016年 览益信息科技. All rights reserved.
//

#import "LYCommentModel.h"
#import "LYUtil.h"
#import "VideoViewContants.h"


@implementation LYCommentUser

@end

@implementation LYCommentShow

@end

@implementation LYCommentToChat

@end


@implementation LYCommentModel

+ (CGFloat)returnHeightWithModel:(LYCommentModel *)model {

    CGFloat cellHeight = 0;
    
    NSString *contentString = @"";
    NSString *nameString = @"";
    if (model.show.user.nickname.length == 0) {
        model.show.user.nickname = @"览益";
    }
    if (model.show.user.nickname.length == 0 || model.show.content.length == 0) {
        return 0;
    }
    if (model.show.user.nickname.length <= 7) {
        nameString = [model.show.user.nickname stringByAppendingString:@": "];
    } else {
        NSString *string1 = [model.show.user.nickname substringToIndex:2];
        NSString *string2 = [model.show.user.nickname substringFromIndex:model.show.user.nickname.length - 4];
        nameString = [nameString stringByAppendingFormat:@"%@...%@: ",string1,string2];
    }
    model.show.content = [model.show.content stringByReplacingOccurrencesOfString:@" " withString:@""];
    
    contentString = [nameString stringByAppendingString:model.show.content];

    CGFloat lineHeight = [LYUtil sizeWithText:contentString
                                         font:[UIFont fontWithName:@"PingFangSC-Regular" size:kVideoCommentCellContentFontSize]
                                        width:SCREEN_WIDTH - 24
                                  lineSpacing: kVideoCommentCellContentLineSpacing].height;
    if (lineHeight < 16) {
        lineHeight = 16;
    }
    cellHeight += (lineHeight + 20);
    return cellHeight;
}

+ (CGFloat)returnHeightFullCommentNewWithModel:(LYCommentModel *)commentModel {
    
    CGFloat cellHeight = 0;
    NSString *contentString = @"";
    NSString *nameString = @"";
    if (commentModel.show.user.nickname.length == 0) {
        commentModel.show.user.nickname = @"览益";
    }
    if (commentModel.show.user.nickname.length == 0 || commentModel.show.content.length == 0) {
       
        return 0;
    }
    if (commentModel.show.user.nickname.length <= 7) {
        nameString = [commentModel.show.user.nickname stringByAppendingString:@": "];
    } else {
        NSString *string1 = [commentModel.show.user.nickname substringToIndex:2];
        NSString *string2 = [commentModel.show.user.nickname substringFromIndex:commentModel.show.user.nickname.length - 4];
        nameString = [nameString stringByAppendingFormat:@"%@...%@: ",string1,string2];
    }
    contentString = [nameString stringByAppendingString:commentModel.show.content];
   
    CGFloat height = [LYUtil sizeWithText:contentString
                                     font:[UIFont fontWithName:@"PingFangSC-Regular" size:kVideoFullScrCommentCellContentFontSize]
                                    width:kVideoFullScrCommentCellContentMaxWidth
                              lineSpacing: kVideoCommentCellContentLineSpacing].height;
    cellHeight += (height + 30);
   
    return cellHeight;

}

@end
